﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Micronet.OpenWeb.Utils;
using Micronet.OpenWeb.Com.BLL;
using Micronet.OpenWeb.Com.Controls;

namespace Micronet.OpenWeb.OpenWeb.Admin.Views.Shared.OpenPersonality
{
    public partial class HomeProfileWorkProcessAdmin : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //var z = OwOpenHomeProfileNationalitiesProcessBLL.OwGetAll();
            //foreach (var owOpenHomeProfileNationalitiesProcessEntity in z)
            //{
            //    if (owOpenHomeProfileNationalitiesProcessEntity.OpenHomeProfileNationalityProcessID > 20)
            //    {
            //        OwOpenHomeProfileNationalitiesProcessBLL.OwDelete(owOpenHomeProfileNationalitiesProcessEntity);
            //    }
            //}

            //var a = OwOpenHomeProfileEducationProcessBLL.OwGetAll();
            //foreach (var ai in a)
            //{
            //    if (ai.OpenHomeProfileEducationProcessID > 20)
            //    {
            //        OwOpenHomeProfileEducationProcessBLL.OwDelete(ai);
            //    }
            //}

            //var b = OwOpenHomeProfileWorkProcessBLL.OwGetAll();
            //foreach (var bi in b)
            //{
            //    if (bi.OpenHomeProfileWorkProcessID > 20)
            //    {
            //        OwOpenHomeProfileWorkProcessBLL.OwDelete(bi);
            //    }
            //}

            //var c = OwOpenHomeProfileLivingProcessBLL.OwGetAll();
            //foreach (var ci in c)
            //{
            //    if (ci.OpenHomeProfileLivingProcessID > 20)
            //    {
            //        OwOpenHomeProfileLivingProcessBLL.OwDelete(ci);
            //    }
            //}

            //var y = OwOpenHomeProfileDetailsBLL.OwGetAll();
            //foreach (var owOpenHomeProfileDetailsEntity in y)
            //{
            //    if (owOpenHomeProfileDetailsEntity.OpenHomeProfileDetailID > 20)
            //    {
            //        OwOpenHomeProfileDetailsBLL.OwDelete(owOpenHomeProfileDetailsEntity);
            //    }
            //}

            //var x = OwOpenHomeProfilesBLL.OwGetAll();
            //foreach (var owOpenHomeProfilesEntity in x)
            //{
            //    if (owOpenHomeProfilesEntity.OpenHomeProfileID > 20)
            //    {
            //        OwOpenHomeProfilesBLL.OwDelete(owOpenHomeProfilesEntity);
            //    }
            //}

            HomeProfileWorkProcessGrid.ItemCommand += new Telerik.Web.UI.GridCommandEventHandler(HomeProfileWorkProcessGrid_ItemCommand);
        }

        void HomeProfileWorkProcessGrid_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "InitInsert")
            {
                Response.Redirect("../Site/HomeProfileWorkProcessEdit.aspx");
            }
        }
        protected void IsDeletedCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            var isDeletedCheckBox = (OwCheckBox)sender;
            var obj = OwOpenHomeProfileWorkProcessBLL.OwGetEntity(isDeletedCheckBox.Text.Trim().OwToInt64TryParse());
            //Response.Write(obj.OpenHomeProfileDetailID);
            obj.IsDeleted = isDeletedCheckBox.Checked.ToString().OwToBoolean();
            if (OwOpenHomeProfileWorkProcessBLL.OwSave(obj) > 0)
            {
                HomeProfileWorkProcessGrid.Rebind();
                //Alert();
            }
        }
    }
}